package com.example.testdemoutils.openFeign;

import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * 测试使用openFeign调用远程rul请求
 */
@RestController
public class TestFeignController {
    @Resource
    FeignService feignService;
    @Resource
    GptService3 gptService3;

    @GetMapping("test")
    public String test() {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("images", "asdasda");
        jsonObject.put("deblockingReason", "qq");
        jsonObject.put("userId", 100003042);
        jsonObject.put("reportTime", 1);
        jsonObject.put("status", -1);

        String message = feignService.getMessage(jsonObject);
        return message;
    }

    @GetMapping("test2")
    public String test2(HttpServletRequest request) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("model", "gpt-3.5-turbo");
        JSONArray objects = new JSONArray();
        JSONObject jsonObject2 = new JSONObject();
        jsonObject2.put("role", "user");
        jsonObject2.put("content", "测试");
        objects.add(jsonObject2);
        jsonObject.put("messages", objects);

        String message = gptService3.getMessage(jsonObject, "Bearer sk-5p0w1PEdb2fnJVUoE0636702204b4aC0Bc497aEc9e525b4f");
        return message;
    }

}
